Class Observer

java.lang.Object
es.csic.iiia.fabregues.dip.Observer
Direct Known Subclasses:
Player

public abstract class Observer
extends java.lang.Object
Observer of the game. It cannot play.
Author:
Angela Fabregues, IIIA-CSIC, fabregues@iiia.csic.es
  • Field Summary

    Fields 
    Modifier and Type Field Description
    protected Comm comm  
    protected Game game  
    es.csic.iiia.fabregues.utilities.Interface log  
    java.lang.String logPath  
    protected java.lang.String mapName  
    protected java.lang.String name  
    protected int pressLevel  
    protected java.lang.String version  
    java.lang.String winner  
  • Constructor Summary

    Constructors 
    Constructor Description
    Observer()
    Observer constructor
    Observer​(java.lang.String logPath)  
  • Method Summary

    Modifier and Type Method Description
    abstract void afterOldPhase()
    Deprecated.
    use phaseEnd instead
    abstract void beforeNewPhase()
    does something when the phase starts
    void exit()
    ends the game
    int getBuildTimeLimit()
    Returns the deadline for build phases (WIN) in milliseconds.
    Game getGame()  
    int getMoveTimeLimit()
    Returns the deadline for move phases (SPR and FAL) in milliseconds.
    java.lang.String getName()  
    int getRetreatTimeLimit()
    Returns the deadline for retreat phases (SUM and AUT) in milliseconds.
    java.lang.String getVersion()  
    void handleCCD​(java.lang.String string)  
    void handleServerOFF()
    ends the game when the server is off
    void handleSlo​(java.lang.String winner)
    ends the game when someone has won.
    void handleSMR​(java.lang.String[] message)  
    abstract void init()
    does something before the game has started
    void mapConfirmation()  
    void phaseEnd​(GameState gameState)
    Does something when the phase ends and before a new one starts
    abstract void receivedOrder​(Order order)
    does something with every received last phase written order
    void setGame​(Game game)  
    void setMap​(java.lang.String map)
    saves the name of the map.
    void start​(IComm comm)
    Observer start
    void start​(IComm comm, boolean enableLogging)  
    void start​(IComm commImpl, es.csic.iiia.fabregues.utilities.Interface log)
    Observer start reusing log file

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • comm

      protected Comm comm
    • game

      protected Game game
    • mapName

      protected java.lang.String mapName
    • name

      protected java.lang.String name
    • version

      protected java.lang.String version
    • pressLevel

      protected int pressLevel
    • log

      public es.csic.iiia.fabregues.utilities.Interface log
    • logPath

      public java.lang.String logPath
    • winner

      public java.lang.String winner
  • Constructor Details

    • Observer

      public Observer()
      Observer constructor
    • Observer

      public Observer​(java.lang.String logPath)
  • Method Details

    • start

      public void start​(IComm comm, boolean enableLogging) throws CommException
      Throws:
      CommException
    • start

      public void start​(IComm comm) throws CommException
      Observer start
      Parameters:
      ip -
      port -
      name -
      Throws:
      java.io.IOException
      CommException
      CommException
    • start

      public void start​(IComm commImpl, es.csic.iiia.fabregues.utilities.Interface log) throws CommException
      Observer start reusing log file
      Parameters:
      ip - of the server
      port - of the server
      name - of the observer
      log - file
      Throws:
      CommException
      java.io.IOException
      CommException
    • setMap

      public void setMap​(java.lang.String map) throws CommException
      saves the name of the map. If the map is the standard, it builds the game. Otherwise, it requests a map definition, MDF.
      Parameters:
      map -
      Throws:
      CommException
    • handleSlo

      public void handleSlo​(java.lang.String winner)
      ends the game when someone has won.
      Parameters:
      winner -
    • handleServerOFF

      public void handleServerOFF()
      ends the game when the server is off
    • exit

      public void exit()
      ends the game
    • mapConfirmation

      public void mapConfirmation() throws CommException
      Throws:
      CommException
    • init

      public abstract void init()
      does something before the game has started
    • receivedOrder

      public abstract void receivedOrder​(Order order)
      does something with every received last phase written order
    • afterOldPhase

      public abstract void afterOldPhase()
      Deprecated.
      use phaseEnd instead
      Does something when the phase ends and before a new one starts
    • beforeNewPhase

      public abstract void beforeNewPhase() throws CommException
      does something when the phase starts
      Throws:
      CommException
    • setGame

      public void setGame​(Game game)
    • getGame

      public Game getGame()
    • getName

      public java.lang.String getName()
    • getVersion

      public java.lang.String getVersion()
    • getMoveTimeLimit

      public int getMoveTimeLimit()
      Returns the deadline for move phases (SPR and FAL) in milliseconds.
    • getRetreatTimeLimit

      public int getRetreatTimeLimit()
      Returns the deadline for retreat phases (SUM and AUT) in milliseconds.
    • getBuildTimeLimit

      public int getBuildTimeLimit()
      Returns the deadline for build phases (WIN) in milliseconds.
    • handleSMR

      public void handleSMR​(java.lang.String[] message)
    • phaseEnd

      public void phaseEnd​(GameState gameState)
      Does something when the phase ends and before a new one starts
      Parameters:
      gameState -
    • handleCCD

      public void handleCCD​(java.lang.String string)